package cs.ubbcluj.ro.mps.presolve.implementation;

import cs.ubbcluj.ro.datatypes.interfaces.Matrix;
import cs.ubbcluj.ro.datatypes.interfaces.Vector;
import cs.ubbcluj.ro.mps.presolve.interfaces.PresolveInterface;

public class PresolveEmptyRows implements PresolveInterface {
	
	private Matrix A;
	private Vector b;
	private boolean row;
	private int index;
	
	public PresolveEmptyRows(Matrix A,Vector b){
		this.A=A;
		this.b=b;
	}
	
	public void presolve() throws InterruptedException{
		for (int i=0; i<A.getNrOfRows(); i++){
			boolean isEmpty = true;
			int j=0;
			while ((j<A.getNrOfColumns()) && isEmpty){
				if (A.get(i,j) != 0){
					isEmpty=false;
				}
				else
					j++;
			}
			if (isEmpty && b.get(i) == 0){
				A.deleteRow(i);
				row=true;
				index=i;
			}
		}
	}
}
